//官方圈子-模板

//引入组件库
var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var circleHelper = require("helper/circle");
var http = require("helper/http");

//声明UI变量
var root=ui("$");  //$表示当前视图的根UI
//var do_ALayout_main=ui("do_ALayout_main");
var do_ImageView_icon=ui("do_ImageView_icon");
var do_Label_title=ui("do_Label_title");
var do_Label_desc=ui("do_Label_desc");

var segment4TagName = ui("segment4TagName");
var listdata4TagName = mm("do_ListData");
segment4TagName.bindItems(listdata4TagName);

//设置数据绑定的映射关系
root.setMapping({
	"do_Label_title.tag":"id",
	"do_Label_title.text":"name",
	"do_Label_desc.text":"remark",
	"do_ImageView_icon.source":"fullLogo",
	"lableMemberCount.tag":"memberCount",
	"lableCategoryName.text":"categoryName",
	"segment4TagName.tag" : "tagNameStr",
	"lableNewCount.tag" : "newTopicCount"
});
//处理成员数量-显示
root.on("dataRefreshed", function(){
	var memberCount = ui("lableMemberCount").tag;
	if(memberCount>0){
		ui("lableMemberCount").text = memberCount+"人";
	}
	var categoryName = ui("lableCategoryName").text;
	if(categoryName ==null || categoryName==""){
		ui("do_LinearLayout_Category").visible = false;
	}else{
		ui("do_LinearLayout_Category").visible = true;
	}
	var newTopicCount = ui("lableNewCount").tag;
	if(newTopicCount > 0){
		ui("lableNewCount").text = "["+newTopicCount+"条]";
		ui("lableNewCount").visible = true;
		ui("aLayoutNewTip").visible = true;
	}else{
		ui("lableNewCount").visible = false;
		ui("aLayoutNewTip").visible = false;
	}
	var jsonTagNames = [];
	listdata4TagName.removeAll();
	var tagNames = ui("segment4TagName").tag;//标签
	if(null!=tagNames && ""!=tagNames){
		var tagNamesList = tagNames.split(",");
		if(tagNamesList.length>0){
			for (var i = 0; i < tagNamesList.length; i++) {
				if(i>=4){//限制显示4个
					break;
				}
				jsonTagNames.push({
					index: i,
					tagname : tagNamesList[i]
				});
			}
			listdata4TagName.addData(jsonTagNames);
			segment4TagName.refreshItems();
		}
	}else{
		segment4TagName.refreshItems();
	}
	ui("do_LinearLayout_6").redraw();
});

